package com.logic.saas.service.subscription;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.logic.saas.enums.KindEnum;
import com.logic.saas.persistence.SubscriptionMapper;
import com.logic.saas.pojo.Ps;
import com.logic.saas.pojo.Qcode;
import com.logic.saas.pojo.SubscriptionInfo;
import com.logic.saas.service.BaseService;
import com.logic.saas.service.QcodeService;
@Service
public class SubscriptionService extends BaseService{

	@Autowired
	private QcodeService qcodeService;
	@Autowired
	private SubscriptionMapper subscriptionMapper;
	
	public List<Qcode> getSubPeriod() throws Exception{
		return qcodeService.getQcodesByKindName(KindEnum.SUBSCRIPTION_PERIOD.getShortName());
	}
	
	/**
	 * insert Subscription Information
	 * @param subscriptionInfo
	 * @return
	 * @throws Exception
	 */
	public boolean insertSubscriptionInfo(SubscriptionInfo subscriptionInfo) throws Exception{
		boolean flag = false;
		Map<String , Object> paramMap = new HashMap<String, Object>();
		paramMap.put("subscription", subscriptionInfo);
		Ps ps = new Ps(paramMap);
		subscriptionMapper.insertSubscriptionInfo(ps);
		flag = true;
		return flag;
	}
	
}
